home *** CD-ROM | disk | FTP | other *** search
- !!Script
- // Copyright ⌐ 1997-2001 - Modelworks Software
- /**
- @Tool: Command Line~defines the command line toolbar.
- @EndTool:
- @Summary: ommand Line~defines the command line toolbar
- */
-
- var gCommandLineComboBox = newToolBarButton("combobox");
- var gDirectoryComboBox = newToolBarButton("combobox");
- var gCommandLineMapfile = getMapFile("CommandLine.map");
- var gCommandLineWidth = 375;
- var gDirectoryWidth = 175;
-
- function DoCommand()
- {
- var toolBar = newToolBar("Command Line", "docked");
- setGlobal("CommandLineToolbar", toolBar);
- if (toolBar)
- {
- var label = newToolBarButton("label");
- label.width = 60;
- label.text = "Command:";
- toolBar.appendButton(label);
-
- gCommandLineComboBox.dropDownHeight = 150;
- gCommandLineComboBox.width = gCommandLineWidth;
- gCommandLineComboBox.scriptHandler = getScriptPath();
- gCommandLineComboBox.onDropDownHandler = "OnCommandShowDropDown";
- gCommandLineComboBox.onTextChangeHandler = "OnCommandTextChange";
- gCommandLineComboBox.onReturnHandler = "OnCommandReturnKeyPressed";
- toolBar.appendButton(gCommandLineComboBox);
-
- gCommandLineComboBox.text = gCommandLineMapfile.lookup("CurrentCommand", "");
- setGlobal("CommandLine.CommandLineComboBox", gCommandLineComboBox);
-
- var insertButton = newToolBarButton( "menu" );
- insertButton.scriptPath = "\\Toolbars\\Command\\insertCommand.script";
- insertButton.imagePath = "\\Toolbars\\Images\\Command\\insert.bmp";
- insertButton.description = "Insert Command";
- insertButton.toolTipText = "Insert Command";
- var insertButtonID = toolBar.appendButton( insertButton );
- setGlobal("CommandLine.InsertButtonID", insertButtonID);
-
- var label = newToolBarButton("label");
- label.width = 60;
- label.text = "Directory:";
- toolBar.appendButton(label);
-
- gDirectoryComboBox.dropDownHeight = 150;
- gDirectoryComboBox.width = gDirectoryWidth;
- gDirectoryComboBox.scriptHandler = getScriptPath();
- gDirectoryComboBox.onDropDownHandler = "OnDirectoryShowDropDown";
- gDirectoryComboBox.onTextChangeHandler = "OnDirectoryTextChange";
- gDirectoryComboBox.onReturnHandler = "OnDirectoryReturnKeyPressed";
- toolBar.appendButton(gDirectoryComboBox);
- setGlobal("CommandLine.ChooseDirectoryComboBox", gDirectoryComboBox);
-
- gDirectoryComboBox.text = gCommandLineMapfile.lookup("CurrentDirectory", "");
- setGlobal("CommandLine.DirectoryComboBox", gDirectoryComboBox);
-
- var insertButton = newToolBarButton( "menu" );
- insertButton.scriptPath = "\\Toolbars\\Command\\insertDirectory.script";
- insertButton.imagePath = "\\Toolbars\\Images\\Command\\insert.bmp";
- insertButton.description = "Insert Directory";
- insertButton.toolTipText = "Insert Directory";
- var insertButtonID = toolBar.appendButton( insertButton );
- setGlobal("CommandLine.InsertButtonID", insertButtonID);
-
- var separatorButton = newToolBarButton( "separator" );
- toolBar.appendButton( separatorButton );
-
- var runButton = newToolBarButton( "icon" );
- runButton.scriptPath = "\\Toolbars\\Command\\run.script";
- runButton.imagePath = "\\Toolbars\\Images\\Command\\run.bmp";
- runButton.description = "Run Command";
- runButton.toolTipText = "Run Command";
- var runCommandID = toolBar.appendButton( runButton );
- setGlobal("CommandLine.RunCommandID", runCommandID);
- }
- toolBar.restoreState();
-
- }
-
-
- function OnCommandShowDropDown()
- {
- var list = gCommandLineMapfile.lookup("CommandList", null);
- if (list == null)
- {
- list = newList();
- gCommandLineMapfile.add("CommandList", list);
- }
- return list;
- }
-
-
- function OnCommandInsertTextChange()
- {
- // Empty
- }
-
- function OnCommandInsertReturnKeyPressed()
- {
- // Empty
- }
-
- function OnDirectoryShowDropDown()
- {
- var list = gCommandLineMapfile.lookup("DirectoryList", null);
- if (list == null)
- {
- list = newList();
- gCommandLineMapfile.add("DirectoryList", list);
- }
- return list;
- }
-
- function OnDirectoryTextChange()
- {
- gCommandLineMapfile.add("CurrentDirectory", gDirectoryComboBox.text);
- }
-
- function OnDirectoryReturnKeyPressed()
- {
- // Empty
- }
-
- // Does not work to automatically resize the toolbar
- function OnNotify(event, cookie)
- {
- var toolbar = getGlobal("CommandLineToolbar");
- if (toolbar && event == "window.sized")
- {
- var screen = Application.getWindowRect();
- var width = (screen.right - screen.left - 250)/4;
-
- var commandLineComboBox = getGlobal("CommandLine.CommandLineComboBox");
- if (commandLineComboBox)
- {
- commandLineComboBox.width = 3*width;
- }
-
- var directoryComboBox = getGlobal("CommandLine.ChooseDirectoryComboBox");
- if (directoryComboBox)
- {
- directoryComboBox.width = width;
- }
- }
- }
-
-
- !!/Script
-
-